package gsp420;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class EventHandler implements  KeyListener, MouseListener, MouseMotionListener
{
	/** the game that will be altered by these events */
	GamePanel m_g;
	
	@Override
	public void keyPressed(KeyEvent e)
	{
		m_g.handleKeyEvent(e);
		m_g.repaint();	// suggestion to the VM to ask the GamePalen to repaint itself
	}
	@Override
	public void keyReleased(KeyEvent e){}
	@Override
	public void keyTyped(KeyEvent e){}

	@Override
	public void mouseClicked(MouseEvent e){System.out.println("clicked");}
	@Override
	public void mouseEntered(MouseEvent e){System.out.println("enter");}
	@Override
	public void mouseExited(MouseEvent e){System.out.println("exit");}
	@Override
	public void mousePressed(MouseEvent e)
	{
		m_g.setPosition(e.getX(), e.getY());
		m_g.repaint();
	}
	@Override
	public void mouseReleased(MouseEvent e){System.out.println("release");}
	public EventHandler(GamePanel a_g)
	{
		m_g = a_g;
	}
	@Override
	public void mouseDragged(MouseEvent e)
	{
		m_g.setPosition(e.getX(), e.getY());
		m_g.repaint();
	}
	@Override
	public void mouseMoved(MouseEvent e)
	{
	}
}
